package com.nisco.dms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.nisco.dms.entity.Program;
import com.nisco.dms.repository.ProgramDao;
import com.nisco.dms.util.dwz.Page;
import com.nisco.dms.util.dwz.PageUtils;
@Component
@Transactional(readOnly=true)
public class ProgramService extends BaseService<Program, String>
{
	@Autowired
	private ProgramDao programDao;
	

	/**
	 * 必须提供空的构造函数以便spring实例化
	 */
	public ProgramService()
	{
	}
	
	@Autowired
	public ProgramService(ProgramDao programDao)
	{
		super((JpaRepository<Program, String>)programDao);
		this.programDao = programDao;
	}


	public  List<Program> findAll(Page page)
	{
		org.springframework.data.domain.Page<Program> pageProgram=programDao.findAll(PageUtils.createPageable(page));
		PageUtils.injectPageProperties(page, pageProgram);
		return pageProgram.getContent();
		
	}
	
	public  List<Program> findProgramByKeywords(Page page,String keywords)
	{
		org.springframework.data.domain.Page<Program> pageProgram=programDao.findByStrSnOrStrNameOrStrDesc(PageUtils.createPageable(page), keywords);
		PageUtils.injectPageProperties(page, pageProgram);
		return pageProgram.getContent();
	}
	
	
	public  List<Program> findBymenuListId(Page page,String menuId)
	{
		org.springframework.data.domain.Page<Program> pageProgram=programDao.findBymenuListId(PageUtils.createPageable(page), menuId);
		PageUtils.injectPageProperties(page, pageProgram);
		return pageProgram.getContent();
	}
	
	 public  Program findOne(String id)
	 {
		 return programDao.findOne(id);
	 }

}
